package com.example.admin.mapper;



import com.example.common.annotation.AutoFill;
import com.example.model.supplier.dto.SupplierProductDTO;
import com.example.model.supplier.pojo.Supplier;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SupMapper {

    List<SupplierProductDTO> page(String supplierName, String productName);
//查询回显
    @Select("select * from sm.product_supplier where supplier_id=#{id}")
    SupplierProductDTO selectById(Integer id);

//删除
    void DeleteAllId(List<Integer> ids);

//更新
    @AutoFill
    @Update("UPDATE sm.product_supplier " +
            "SET product_id = #{productId}, " +
            "supplier_id = #{supplierId}, " +
            "product_name = #{productName}, " +
            "supplier_name = #{supplierName}, " +
            "supplier_phone = #{supplierPhone}, " +
            "supplier_address = #{supplierAddress}, " +
            "supply_date = #{supplyDate}, " +
            "quantity = #{quantity}, " +
            "price = #{price}, " +
            "last_operation_time = #{lastOperationTime}, " +
            "last_operator = #{lastOperator} " +
            "WHERE supplier_id = #{supplierId}")
    void updateById(SupplierProductDTO supplier);

//    增加
    @Insert("INSERT INTO sm.product_supplier (product_id, supplier_id, product_name, supplier_name, supplier_phone, supplier_address, supply_date, quantity, price, last_operation_time, last_operator) " +
        "VALUES ( #{productId}, #{supplierId}, #{productName}, #{supplierName}, #{supplierPhone}, #{supplierAddress}, #{supplyDate}, #{quantity}, #{price}, #{lastOperationTime}, #{lastOperator})")
         void save(SupplierProductDTO supplierProductDTO);

}
